package com.solveit.aps;


public abstract class IdAndNameBasedEntity {
	
	public abstract Integer getId();
	public abstract String getName();
	@Override
	public boolean equals(Object obj){
		if (obj==null)
			return false;
		if(!getClass().equals(obj.getClass())){
			return false;
		}
		IdAndNameBasedEntity other = (IdAndNameBasedEntity)obj;
		if (getId()==null || getId()<=0 || other.getId()==null || other.getId()<=0)
			return super.equals(obj);
		else
			return getId().equals(other.getId());
	}
	
	@Override
	public int hashCode(){
		return getId()==null || getId()<=0?super.hashCode():getId();
	}

}
